﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RSSReader.classesCustom;

namespace RSSReader.pageswithContent
{
    public partial class SavedContent : System.Web.UI.Page
    {
        private UserDataHandler udh;

        protected void Page_Load(object sender, EventArgs e)
        {
            //get object from session state
            udh = (UserDataHandler)Session["userDataHandler"];

        }

        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (articlesGrid.SelectedRow == null)
            {
                FormView1.Visible = false;
            }
            else
            {
                FormView1.Visible = true;
            }

        }

        protected void ObjectDataSourceForOnlineArticles_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
        {
            e.ObjectInstance = udh;
        }

        protected void ObjectDataSourceArticleDetail_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
        {
            e.ObjectInstance = udh;
        }
        
        protected void deleteButton_Click(object sender, EventArgs e)
        {
            udh.deleteUserCustomSQLArticle((int)articlesGrid.SelectedDataKey.Value);
            articlesGrid.DataBind();
            articlesGrid.SelectedIndex = -1;            
        }

        protected void ObjectDataSourceForSavedArticles_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
        {
            e.ObjectInstance = udh;
        }

        /*
        protected void jumpButton_Click(object sender, EventArgs e)
        {
            Button bt = (Button)sender;
            FormView fv= (FormView)bt.NamingContainer;
            Label l= (Label)fv.FindControl("weblink");
            //or
            Label linkLabel = (Label)FormView1.FindControl("weblink");            
            //or
            Response.Redirect(dh.getXMLArticle(selectedXMLIndex).weblink);
        }
         * */

    }
}